/**
 * Copyright @ 2013 - 2015 Suntec Software(Shanghai) Co., Ltd.
 * All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are NOT permitted except as agreed by
 * Suntec Software(Shanghai) Co., Ltd.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 */

/**
 * @file ViewController.h
 * @brief Declaration file of class ViewController.
 *
 * This file includes the declaration of class ViewController, and
 * the definitions of the macros.
 *
 * @attention used for C++ only.
 */

#ifndef VIEWCONTROLLER_H
#define VIEWCONTROLLER_H

#ifndef __cplusplus
#    error ERROR: This file requires C++ compilation (use a .cpp suffix)
#endif

#include "qmlframework/NQCreator.h"
#include "ngbase/NGSingleton.h"

/**
 * @brief class ViewController.
 *
 * This class is to control the view of an app.
 *
 * @see add custom qrc prefixs at ViewController::init()
 * @warning return a valid home page if not using MIST at ViewController::startViewId()
 */
class ViewController: public NQCreator, NGWeakSingleton<ViewController>
{
public:
    /// constrctor.
    ViewController(AppId appId);

    /// destructor.
    ~ViewController();

    /// view initializatin.
    void init();

    /// return a valid home page if not using MIST.
    NGViewId startViewId();
};

///< definition of ViewControllerInst macro to get a sigleton of class ViewController.
#define ViewControllerInst NGWeakSingleton<ViewController>::inst()

#endif /* VIEWCTROLLER_H */
/* EOF */
